package jobs;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.LinkedList;

import models.Contract;
import models.Product;
import play.jobs.Job;
import play.jobs.OnApplicationStart;

@OnApplicationStart
public class Bootstrap extends Job{
	
	public void doJob() {
/*		   DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
		   Date date = new Date();
			Calendar cal = Calendar.getInstance();
			cal.setTime(date);		   
		   ArrayList<Product> pl = new ArrayList<Product>();
		   
		   Product p1 = new Product("Mop", 1, 2, 10.0, "لمون", new LinkedList<Date>(), "floor type");
			if (p1.number_of_changes == 2) {
				Date d;
				cal.add(Calendar.DATE, 14);
				d = cal.getTime();
				p1.change_time_list.addLast(d);
				for(int i =0;i<23;i++)
				{
					cal.setTime(p1.change_time_list.getLast());
					cal.add(Calendar.DATE, 14);
					d = cal.getTime();
					p1.change_time_list.addLast(d);											
				}
			}
			p1.save();
			pl.add(p1);		   
			
			Contract c = new Contract("Michael Ibraam", "Remon Samer", "01206535301", "01225319339", "0235698658", "0212345678", "A", 4571, 13, date, "19 Abd el ftah el haram", "floor type", null);
			c.plist=pl;
			c.products = pl;
			//	System.out.println(c.plist.size());
			//c.save();
			//System.out.println(c.plist.get(0).change_time_list.getFirst());
		   org.hsqldb.util.DatabaseManagerSwing.main(new String[] { "--url",
				"jdbc:hsqldb:mem:playembed", "--noexit" });
*/
	}

}
